home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / newsgrp / group94a.txt / 000099_icon-group-sender _Mon Apr 25 08:12:44 1994.msg < prev    next >
Internet Message Format  |  1994-08-19  |  1KB

  1. Received: by cheltenham.cs.arizona.edu; Mon, 25 Apr 1994 09:25:47 MST
  2. Date: Mon, 25 Apr 94 08:12:44 PDT
  3. From: kwalker@sirtur.premenos.com (Ken Walker)
  4. Message-Id: <9404251512.AA00951@sirtur.premenos.com>
  5. To: icon-group@cs.arizona.edu
  6. Subject: pointer semantics
  7. X-Sun-Charset: US-ASCII
  8. Content-Length: 1002
  9. Status: R
  10. Errors-To: icon-group-errors@cs.arizona.edu
  11.  
  12. > From: <janpeter@mpi.kun.nl>
  13. > Subject: Re: is this a bug? 
  14. > For example, the following fragments do not have the same
  15. > meaning:
  16. > # first fragment
  17. > t := table([])
  18. > put(t[1],"john")
  19. > put(t[2],"mary")
  20. > # second fragment
  21. > t := table([])
  22. > t[1] |||:= ["john"]
  23. > t[2] |||:= ["mary"]
  24. > Which is a pity, I think, for a higher level language where
  25. > you're supposed to be free of these details
  26.  
  27. A simplified example is:
  28.  
  29.    L := []
  30.    put(L, "john")
  31.  
  32.    L := []
  33.    L |||:= ["john"]
  34.  
  35. In the first case, you are modifying the list and in the second case you
  36. are constructing a new list and assigning it to L. The "problem" is
  37. inherent in an imperative language with pointer semantics. While it is
  38. true that efficiency is one reason for having pointer semantics, pointer
  39. semantics is also very convenient. You can modify part of a complex
  40. data structure without being forced to rebuild the whole thing and pass
  41. the changes on to everything that needs it.
  42.  
  43.    Ken Walker, kwalker@premenos.com
  44.